package com.chenju.invokechainservice.dao;

import com.chenju.invokechainservice.domain.TAnnotationNode;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.Query;

import java.util.List;

public interface TAnnotationNodeRepository extends Neo4jRepository<TAnnotationNode, Long> {
    @Query("MATCH (m:TAnnotationNode)-[r:ANNOTATED]->(n:TClassOrInterfaceNode) WHERE m.name=$name AND n.name=$classOrInterfaceName return m")
    TAnnotationNode findByNameAndClassOrInterfaceName(String name, String classOrInterfaceName);

    @Query("MATCH (m:TAnnotationNode)-[r:ANNOTATED]->(n:TMethodNode) WHERE m.name=$name AND n.name=$methodName return m")
    TAnnotationNode findByNameAndMethodName(String name, String methodName);

    List<TAnnotationNode> findByName(String name);
}
